/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       adjusted_bitmap_cache.h

	$Header: /game/adjusted_bitmap_cache.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef ADJUSTED_BITMAP_CACHE_H_INCLUDED
#define ADJUSTED_BITMAP_CACHE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "cached_ptr.h"

class t_bitmap_group;
// -----------------------------------------------------
// load a copy of a bitmap and adjust the brightness.  +15 = white, -15 = black.
// ---------------------------------------------------
class t_adjusted_bitmap_cache_data : public t_abstract_cache_data<t_bitmap_group>
{
public:
	typedef t_abstract_cache<t_bitmap_group>      t_source_cache;

	t_adjusted_bitmap_cache_data( t_source_cache const& source, int brightness );
	virtual ~t_adjusted_bitmap_cache_data();
		                     
protected:
	virtual void            add_reference();
	virtual t_bitmap_group* do_get( t_progress_handler* handler );
	virtual void            remove_reference();

	t_source_cache   m_source;
	int              m_brightness;
	int              m_reference_count;
	t_bitmap_group*  m_data;
};

// -----------------------------------------------------
// load a copy of a bitmap and adjust the brightness.  +15 = white, -15 = black.
// ---------------------------------------------------
class t_adjusted_bitmap_cache : public t_abstract_cache<t_bitmap_group>
{
public:
	typedef t_abstract_cache<t_bitmap_group>      t_source_cache;

	t_adjusted_bitmap_cache();
	t_adjusted_bitmap_cache( t_source_cache const& source, int brightness );
};

inline t_adjusted_bitmap_cache::t_adjusted_bitmap_cache() : t_abstract_cache<t_bitmap_group>(0)
{
}

inline t_adjusted_bitmap_cache::t_adjusted_bitmap_cache( t_source_cache const& source, int brightness )
	: t_abstract_cache<t_bitmap_group>( new t_adjusted_bitmap_cache_data(source, brightness ) )
{
}

#endif // ADJUSTED_BITMAP_CACHE_H_INCLUDED